<?php

namespace Muyuxuanpay\threePay\src\cj\protocolPayment;

use Muyuxuanpay\threePay\BaseTrait;
use Muyuxuanpay\threePay\ProtocolPaymentNotify;
use Muyuxuanpay\threePay\src\cj\CommonTrait;

class Notify implements ProtocolPaymentNotify
{
    use BaseTrait;
    use CommonTrait;
    protected $must = [
        'merchant_id'=>"商户编号",
        'product_code'=>"营销产品编码",
        'function_code'=>"基础产品编码",
        'public_key'=>"公钥",
        'private_key'=>"秘钥",
    ];

    /**
     * 回调参数验签
     * @param array $data
     * @return array
     * @throws \Exception
     */
    public function verifyNotify(array $data)
    {
        $this->verify();
        $biz_content = $data['biz_content']??"";
        if(empty($biz_content)){
            throw new \Exception("biz_content参数为空");
        }
        $biz_content = $this->rsaDecrypt($biz_content);
        try {
            $biz_content = json_decode($biz_content, true);
        }catch (\Exception $e){
            throw new \Exception("biz_content参数解析失败");
        }
        $data['biz_content'] = $biz_content;
        return $data;
    }
    public function sendSuccess()
    {

    }
    public function sendFail()
    {

    }
}